<?php
/**
 * @review is this used? maybe by the api, if
 * it's not, might be a good idea to have an individual template
 * to render the data object for use by api, but maybe as xml
 */
/**
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:modules/
 * @license    GNU/GPL
*/

// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the HelloWorld Component
 *
 * @package    HelloWorld
 */

class calendarViewXml extends JView
{
    function display($tpl = null)
    {
		//var_dump('xml view');
        $model = $this->getModel();
		//$model->_setBuild('detail');
        $data =  $this->get('Data');
		$xml = $this->xml_serializer($data);
		$this->assignRef('xml', $xml);
		
        parent::display($tpl);
    }
	
	function xml_serializer($data)
	{
		//var_dump('xml start serial');
		require_once("XML/Serializer.php");
 		//var_dump('xml after include');
		$options = array(
			'defaultTagName'	=>	'event',
			'indent'			=>	'    ',
			'rootName'			=>	'calendar'
			);
 
		// create object
		$serializer = new XML_Serializer($options);
 		//var_dump('xml after $serializer');
		// perform serialization
		$serializer->serialize($data);
		$result = $serializer->getSerializedData();
		return $result;
	}
}

?>
